import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import login from '../components/Login.vue'

// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
const routes = [
    { path: '/', redirect: '/index' },
    {
        path: '/index', 
        component: () => import('../components/index.vue'), 
        redirect: '/index/homeSwiper',
        children: [
            // 首页管理
            { path: 'homeCategory', component: () => import('../components/page/home/category.vue') },
            { path: 'homeRecommend', component: () => import('../components/page/home/recommend.vue') },
            { path: 'homeSwiper', component: () => import('../components/page/home/swiper.vue') },
            { path: 'homeNews', component: () => import('../components/page/home/news.vue') },
            // 分类管理
            { path: 'categoryBanner', component: () => import('../components/page/category/brand.vue') },
            { path: 'categoryCategory', component: () => import('../components/page/category/category.vue') },
            { path: 'categoryGoods', component: () => import('../components/page/category/goods.vue') },
            { path: 'sku', component: () => import('../components/page/category/sku.vue') },
        ]
    },
    { path: '/login', component: login },
]

const router = new VueRouter({
    routes,
})


export default router